#include <iostream>
#include <string>
#include <initializer_list>
/**
 * @brief 计算列表中所有元素的和
 * 
 * @param i 
 * @return int 
 */
int sum(std::initializer_list<int> i)
{
    int count = 0;
    for(auto begin = i.begin(); begin != i.end(); ++begin)
    {
        count += *begin;   
    }
    std::cout << count << std::endl;
    // 使用范围 for 语句重新写循环
    for(auto value : i)
    {
        count += value;
    }
    return count;
}

int main()
{
    sum({0,1,2,3,4});
    sum({6,7,8});
    return 0;
}